home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
DATABASE.DIR
/
00364_Script_SortIndex
< prev
next >
Wrap
Text File
|
1996-03-28
|
3KB
|
111 lines
-- -----------------------------------------------------------
-- Handler sortIndex cleans up the index cast members
-- ensuring that there are no duplicates in search results and
-- that search results are sorted alphabetically.
--
-- Sample Call:
--
-- confirmIndexCastEndsWithAsterisk 332, 357
-- sortIndex 332, 357
-- confirmIndexCastEndsWithAsterisk 332, 357
-- extractIndexIndex 332, 357
-- spreadIndexIndexToCasts 358, 360
-- -----------------------------------------------------------
on sortIndex firstCast, lastCast
repeat with c = firstCast to lastCast
put "Sorting Index Cast " & c
sortIndexCast c
end repeat
end
-- -----------------------------------------------------------
-- Handler sortIndexCast cleans up one index cast member
on sortIndexCast c
set indexCastText = field c
set sortedText = sortIndexText (indexCastText)
put sortedText into field c
end
-- -----------------------------------------------------------
-- Handler sortIndexText cleans up text passed to it
on sortIndexText T
if T = empty then return empty
set S = ""
set headerLines = ""
repeat with L = 1 to the number of lines of T
if char 1 of line L of T = "*" then
put L & "," after headerLines
end if
end repeat
put the number of chars of headerLines into numChars
if char numChars of headerLines = "," then delete char numChars of headerLines
set numHeaders = the number of items of headerLines - 1
if numHeaders < 1 then return empty
repeat with H = 1 to numHeaders
set firstResultLine = item H of headerLines + 1
set lastResultLine = item H + 1 of headerLines - 1
if lastResultLine < firstResultLine then
put "ALERT: missing data at line "&lastResultLine
end if
set resultText = line firstResultLine to lastResultLine of T
set resultTextProcessed = SortStringAndRemoveDups(resultText)
put (line (firstResultLine - 1) of T) & RETURN & resultTextProcessed into thisResult
put thisResult after S
end repeat
return S
end
-- -----------------------------------------------------------
-- Handler sortStringAndRemoveDups sorts parameter text
-- alphabetically by lines after it has removed duplicate lines
on SortStringAndRemoveDups aString
set aList = []
repeat with L = 1 to the number of lines of aString
if getPos(aList , line L of aString) = 0 then
append(aList, line L of aString)
end if
end repeat
set listSize = count(aList)
if listSize = 0 then return empty
sort aList
set resultString = ""
repeat with C = 1 to listSize
put getAt(aList, C) & RETURN after resultString
end repeat
return resultString
end
-- -----------------------------------------------------------
-- Handler confirmIndexCastEndsWithAsterisk makes sure each
-- index cast ends with an asterisk
on confirmIndexCastEndsWithAsterisk firstCast, lastCast
repeat with c = firstCast to lastCast
set numLines = the number of lines of field c
if line numLines of field c = "" then
put "*" after field c
end if
put "Last line of Index Cast " & c & RETURN & line numLines of field c
end repeat
end